package vip.xiaonuo.facedoor.modular.deviceset.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.facedoor.modular.devicebase.service.DeviceBaseService;
import vip.xiaonuo.facedoor.modular.deviceset.param.DwDeviceSetParam;
import vip.xiaonuo.facedoor.modular.deviceset.service.DwDeviceSetService;

import javax.annotation.Resource;

/**
 * 网点设置表控制器
 *
 * @author 胡鹏达
 * @date 2022-07-09 09:48:37
 */
@RestController
public class DwDeviceSetController {

    @Resource
    private DwDeviceSetService dwDeviceSetService;

    @Resource
    private DeviceBaseService deviceBaseService;

    /**
     * 添加网点设置表
     *
     * @author 胡鹏达
     * @date 2022-07-09 09:48:37
     */
    @PostMapping("/dwDeviceSet/saveOrUpdate")
    @BusinessLog(title = "网点设置表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData saveOrUpdate(@RequestBody DwDeviceSetParam dwDeviceSetParam) {
        dwDeviceSetService.saveOrUpdate(dwDeviceSetParam);
        return new SuccessResponseData();
    }

    /**
     * 远程重启
     *
     * @author 胡鹏达
     * @date 2022-07-09 09:48:37
     */
    @GetMapping("/dwDeviceSet/restart")
    @BusinessLog(title = "远程重启", opType = LogAnnotionOpTypeEnum.OTHER)
    public ResponseData restart(String deviceId) {
        dwDeviceSetService.restart(deviceId);
        return new SuccessResponseData();
    }


    /**
     * 查看网点设置表
     *
     * @author 胡鹏达
     * @date 2022-07-09 09:48:37
     */
    @GetMapping("/dwDeviceSet/detail")
    @BusinessLog(title = "网点设置表_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(DwDeviceSetParam dwDeviceSetParam) {
        return new SuccessResponseData(dwDeviceSetService.detail(dwDeviceSetParam));
    }


}
